<?php 
	$fc = Zend_Controller_Front::getInstance()->getRequest();
	$moduleEnCours = $fc->getModuleName();
	$controllerEnCours = $fc->getControllerName();
	$actionEnCours = $fc->getACtionName();
	$config = Jnd_App::getConfig("team");
	$cache = Ehl_Cache::recuperationCache();
	if ( $cache->test("currentTeam") ) {
		$id = $cache->load("currentTeam");
	} else {
		$id = $config['default'];
	}
	$team = new Administration_Model_Teams($id);
?>
<?php echo $this->doctype()?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $this->titre;?></title>
<?php
	echo $this->headLink()
		->appendStylesheet( $this->baseUrl( 'css/global.css' ) )
		->appendStylesheet( $this->baseUrl( 'css/jquery.autocomplete.css' ) )
		->appendStylesheet( $this->baseUrl( 'css/actions.css' ) );
?>
<link rel="icon" type="image/png" href="images/favicon.png" />
<?php
	$conf_jquery = Jnd_App::getConfig('jquery');
	echo $this->jQuery()->uiEnable()
		->setLocalPath($conf_jquery['path']['min'] . $conf_jquery['file']['normal'])
		->setUiLocalPath($conf_jquery['path']['ui'] . $conf_jquery['file']['ui'])
		->addStylesheet($conf_jquery['path']['css'] . $conf_jquery['theme'] . $conf_jquery['file']['css'])
		->addJavascriptFile('/js/form.js');
	echo $this->headScript();
	echo $this->headStyle();
	$storage = (object)Zend_Auth::getInstance()->getStorage()->read();
	if ( property_exists($storage, "idusers")&& intval($storage->idusers) > 0 ) {
		$this->connected = true;
		$currentUser = new Administration_Model_Users($storage->idusers);
	} else {
		$currentUser = null;
		$this->connected = false;
	}
?>
</head>
<body <?php echo $this->onload;?>>
<div id="container">
	<div id="topbar">
		<div id="connectForm">
		<?php if ( $this->connected ) : ?>
		<img src="<?php echo $this->baseUrl("/images/anonymous.jpg")?>" alt="" /> <?php echo $currentUser->getUsername()?> - <a href="<?php echo $this->smartUrl("index", null, "site", array("logout" => 1));?>"><?php echo __('Disconnect')?></a>	
		<?php else : ?>
		
			<?php 
				$form = $this->formLogin;
				if ( !($form instanceof Jnd_Form) ) {
					$form = new Ehl_Form_Login('Formulaire');
				}	
			?>
			<form id="<?php echo $form->getName()?>" action="<?php echo $form->getAction()?>" method="<?php echo $form->getMethod()?>" enctype="<?php echo $form->getEnctype()?>">
				<?php 
					echo $form->getElement("username")->getLabel() . ':' . $form->getElement("username") . " | ";
					echo $form->getElement("password")->getLabel() . ':' . $form->getElement("password");
					echo $form->getElement("submit");
				?>
			</form>
		<?php endif; ?>
		</div>
	</div>
	<div id="header">
		<div id="logo"><img src="<?php echo $team->getLogo();?>" alt="" /></div>
		<div id="title"><img src="<?php echo $team->getTitle();?>" alt="" /></div>
	</div>
	<div id="site">
		<div id="menu">
			<ul style="width: 100%">
				<li <?php if($moduleEnCours == "site" and $controllerEnCours == "index" and $actionEnCours == "index") echo 'class="current"';?>>
					<a href="<?php echo $this->url( array( 'module'=>'default', 'controller' => 'index' ), 'default', true )?>"><?php echo _('Team Stats')?></a>
				</li>
				<li <?php if($moduleEnCours == "site" and $controllerEnCours == "schedule") echo 'class="current"';?>>
					<a href="<?php echo $this->url( array( 'module'=>'site','controller' => 'schedule' ), 'default', true )?>"><?php echo __('Schedule')?></a>
				</li>
				<li <?php if($moduleEnCours == "default" and $controllerEnCours == "teamroster") echo 'class="current"';?>>
					<a href="<?php echo $this->url( array( 'module'=>'demandes','controller' => 'demandes', 'action' => 'saisie' ), 'default', true )?>"><?php echo __('Team Roster')?></a>
				</li>
				<li <?php if($moduleEnCours == "default" and $controllerEnCours == "press") echo 'class="current"';?>>
					<a href="<?php echo $this->url( array( 'module'=>'demandes','controller' => 'demandes', 'action' => 'saisie' ), 'default', true )?>"><?php echo __('Press')?></a>
				</li>
				<li <?php if($moduleEnCours == "default" and $controllerEnCours == "sponsors") echo 'class="current"';?>>
					<a href="<?php echo $this->url( array( 'module'=>'demandes','controller' => 'demandes', 'action' => 'saisie' ), 'default', true )?>"><?php echo __('Sponsors')?></a>
				</li>
				<li <?php if($moduleEnCours == "default" and $controllerEnCours == "shop") echo 'class="current"';?>>
					<a href="<?php echo $this->url( array( 'module'=>'demandes','controller' => 'demandes', 'action' => 'saisie' ), 'default', true )?>"><?php echo __('Shop')?></a>
				</li>
				<?php if ( !is_null($currentUser) && $currentUser->getAdmin() == 1 ) : ?>
				<li>
					<a href="<?php echo $this->url( array( 'module'=>'administration','controller' => 'index', 'action' => 'index' ), 'default', true )?>" target="_blank"><?php echo __('Administration')?></a>
				</li>
				<?php endif; ?>
				<?php if ( is_null($currentUser) ) : ?>
				<li style="float: right;">
					<a href="<?php echo $this->url( array( 'module'=>'site','controller' => 'index', 'action' => 'panel' ), 'default', true )?>"><?php echo __('Register')?></a>
				</li>
				<?php endif; ?>
			</ul>
		</div>
		<div id="display"> 
		  <?php echo $this->layout()->content?>
		</div>
		<div id="footer">
			<div id="content">
				<br /><?php echo __("Ehlwolves.com is the official website of the ehl wolves. Copyright © 2010 Ecole hôtelière de Lausanne Wolves. All rights reserved. "); ?>
			</div>
		</div>
	</div>
</div>
</body>
</html>
